function lpriord_sum = lmj_priormin(parest, parvec, parposest, indmat, prpar, prss, ssposest, funcmod, solveopt, addsol, flag_transform)
% ======================================================================
% LMJ_PRIORMIN.M
% follow the structure of GENSYSPOST_VEC by Alejandro Justiniano (C)
% IN addition to putting priors on parameters, our current model put
% priors on steady state values.
%
% =======================================================================
lpriord_sum=1e20;

if nargin < 13; flag_transform = 1; end;
if flag_transform ==1 
    [parest,flag_c]=check_min(parest,indmat);
    if flag_c==0;disp('Problems with transformed coefficients');return;end
end
parvec(parposest)=parest;

%% Prior Density of Parameters
lpriord=sum(priordens(parvec, prpar.prior, prpar.alphap, prpar.betap, prpar.lbnd, prpar.ubnd));
if isinf(abs(lpriord))==1;return;end


%% Prior Density on Steady State
[G1, impact, C,eu,SDX,ZZ, junk, ssvec]=feval(funcmod,parvec,solveopt,addsol);
if isempty(ssvec); return; end

lpriord_ss = sum(priordens(ssvec(ssposest), prss.prior, prss.alphap, prss.betap, prss.lbnd, prss.ubnd));
if isinf(abs(lpriord_ss))==1;return;end

%% log prior density
lpriord_sum = -(lpriord + lpriord_ss);
end